package com.yc.home.cloudindex;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@EnableCircuitBreaker
public class CloudIndexApplication implements WebMvcConfigurer {

	public static void main(String[] args) {
		SpringApplication.run(CloudIndexApplication.class, args);
	}

	//远程调用
	@Bean
	@LoadBalanced		//支持负载均衡注解
	RestTemplate restTemplate(){
		return new RestTemplate();
	}

	//静态资源
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry){
		registry.addResourceHandler("/**")
				.addResourceLocations("file:D:\\java\\git\\project\\home\\cloud-index\\src\\main\\resources\\static/");
	}

}
